﻿namespace FileCategorizer.Engine.Data
{
    using System.Collections.Specialized;

    /// <summary>
    /// This interface defines the expected behavior for database classes.
    /// </summary>
    public interface IDatabase
    {
        /// <summary>
        /// Gets a collection of all the paths currently in the directory
        /// database.
        /// </summary>
        StringCollection Directories { get; }

        /// <summary>
        /// Gets a value indicating whether there are tagged files in the 
        /// database.
        /// </summary>
        bool IsEmpty { get; }

        /// <summary>
        /// Adds a path to the directory database.
        /// </summary>
        /// <param name="path">The path to add.</param>
        void AddDirectory(string path);

        /// <summary>
        /// Removes a path from the directory database.
        /// </summary>
        /// <param name="path">The path to remove.</param>
        void RemoveDirectory(string path);

        /// <summary>
        /// Removes all paths from the directory database.
        /// </summary>
        void ClearDirectories();

        /// <summary>
        /// Adds a file to the tag database.
        /// </summary>
        /// <param name="path">The full path of the file to add.</param>
        void AddFile(string path);

        /// <summary>
        /// Removes a file from the tag database, as well as all tags 
        /// associated with that file.
        /// </summary>
        /// <param name="path">The full path of the file to remove.</param>
        void RemoveFile(string path);

        /// <summary>
        /// Associates a specific tag to a file.
        /// </summary>
        /// <param name="path">The full path of the file.</param>
        /// <param name="tag">The tag to add to the file.</param>
        void AddTag(string path, string tag);

        /// <summary>
        /// Removes a specific tag from a file.
        /// </summary>
        /// <param name="path">The full path of the file.</param>
        /// <param name="tag">The tag to remove from the file.</param>
        void RemoveTag(string path, string tag);

        /// <summary>
        /// Gets a value indicating whether this file has the particular
        /// tag.
        /// </summary>
        /// <param name="path">The full path to the file to check.</param>
        /// <param name="tag">The tag to find.</param>
        /// <returns><code>true</code> if the tag is mapped to the file.</returns>
        bool HasTag(string path, string tag);

        /// <summary>
        /// Removes all files and tags from the database.
        /// </summary>
        void ClearTags();

        /// <summary>
        /// Searches the tag database for the file name
        /// </summary>
        /// <param name="name">A string in the file path to locate</param>
        /// <returns>A collection of string matching the <code>name</code> substring.</returns>
        StringCollection SearchByName(string name);

        /// <summary>
        /// Searches the tag database for the file with the specified tag.
        /// </summary>
        /// <param name="tag">The tag to find.</param>
        /// <returns>A collection of file paths mapped to the specified tag.</returns>
        StringCollection SearchByTag(string tag);
    }
}